package com.shop.shop.controller;

import com.shop.shop.dao.ChartMapper;
import com.shop.shop.model.Chart;
import com.shop.shop.model.ChartMysql;
import com.shop.shop.model.Good;
import com.shop.shop.model.GoodCount;
import com.shop.shop.service.ChartService;
import com.shop.shop.util.MysqlTransferUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/chart")
public class ChartController {

    @Resource
    ChartMapper chartMapper;

    @Resource
    ChartService chartService;
    @RequestMapping("/get")
    public List<Chart> getAllData() {
        return MysqlTransferUtils.transferToChartList(chartMapper.getAllData());
    }

    @RequestMapping("/add")
    public Chart addGood(Chart chart, GoodCount good){
        return chartService.addGood(chart,good);
    }

}
